package fr.babostesting.stage3 
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageQuality;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Rectangle;
	import flash.utils.setTimeout;
	import starling.core.Starling;
	
	/**
	 * ...
	 * @author ...
	 */
	public class Test extends Sprite 
	{
		private var _starling:Starling;
		
		public function Test ()
		{
			if (stage != null)
				init();
			else
				addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init (event:Event = null):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.quality = StageQuality.LOW;
			
			stage.addEventListener(Event.RESIZE, stageResizedHandler);
			
			setTimeout(startUI, 1);
		}
		
		protected function stageResizedHandler (event:Event):void
		{
			if (_starling != null)
			{
				_starling.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
				
				_starling.stage.stageWidth = stage.stageWidth;
				_starling.stage.stageHeight = stage.stageHeight;
			}
		}
		
		protected function startUI ():void
		{
			_starling = new Starling(ListBaseClass, stage);
			
			_starling.showStats = true;
			
			_starling.antiAliasing = 0;
			
			_starling.start();
		}
	}
}